#include "git-upstream.h"

#include "git-remote-track-branch.h"
#include "git-local-branch.h"

namespace git
{

Upstream::Upstream(Upstream &&b)
    : remote_(b.remote_)
    , local_(b.local_) {

    b.remote_ = nullptr;
    b.local_ = nullptr;
}

Upstream::Upstream(RemoteTrackBranch &&remote)
    : remote_(new RemoteTrackBranch(std::move(remote))) {
}

Upstream::Upstream(LocalBranch &&local)
    : local_(new LocalBranch(std::move(local))) {
}

Upstream::~Upstream() {
    delete local_;
    local_ = nullptr;
    delete remote_;
    remote_ = nullptr;
}

Upstream &Upstream::operator=(Upstream &&b) {
    if (this != &b && (remote_ != b.remote_ || local_ != b.local_)) {
        delete local_;
        delete remote_;
        remote_ = b.remote_;
        local_ = b.local_;
        b.remote_ = nullptr;
        b.local_ = nullptr;
    }
    return *this;
}

} // namespace git
